Skip to content

feat: add TryFrom/TryInto bounds, from_byte() method, Sized bound, and u128 support to LinkReference#145

Merged
konard merged 5 commits intomainfrom
issue-144-768413419d48
Apr 14, 2026
Merged

feat: add TryFrom/TryInto bounds, from_byte() method, Sized bound, and u128 support to LinkReference#145
konard merged 5 commits intomainfrom
issue-144-768413419d48

Conversation

@konard
Copy link
Copy Markdown
Member

@konard konard commented Apr 14, 2026

Summary

Extends LinkReference trait to serve as the single unified trait for the Links Platform ecosystem, addressing the trait fragmentation between platform-data, platform-trees, and doublets-rs.

Changes to LinkReference

  • TryFrom<T> and TryInto<T> for all 12 integer types (i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize) with Error: Debug bounds
  • from_byte(n: u8) -> Self default method — convenience method for creating small constants from u8 values, replacing the FuntyPart trait from platform-data
  • Sized bound — required by platform-trees's LinkType
  • Explicit u128 supportu128 is now a documented and tested LinkReference implementor, enabling very large link address spaces

Supported LinkReference types

u8, u16, u32, u64, u128, usize

All bounds are already satisfied by these concrete types via the blanket impl, making this a backwards-compatible addition.

Expected ecosystem impact

  • platform-data can replace funty::Unsigned + FuntyPart with LinkReference (data-rs#16)
  • platform-trees can replace Number + Unsigned + TryFrom<u8> + FromPrimitive with LinkReference (trees-rs#30)
  • doublets-rs can use a single T: LinkReference bound (doublets-rs#48)
  • funty dependency eliminated from the ecosystem
  • from_byte() replaces funty() — no more cryptic external crate references

Why from_byte (not from_u8 or funty)

  • from_u8 conflicts with FromPrimitive::from_u8 (already a supertrait), causing ambiguity at call sites
  • funty references an external crate that is being eliminated
  • from_byte is unambiguous, descriptive, and collision-free

Test plan

  • All 96 tests pass locally (cargo test) — 5 new u128-specific tests
  • All 6 doctests pass
  • cargo clippy --all-targets passes with no warnings
  • cargo fmt --check passes
  • Tests cover: TryFrom bounds, TryInto bounds, from_byte method, Sized bound, Error: Debug bound
  • u128 tested for: LinkReference trait impl, from_byte (full 0-255 range), TryFrom all integer types, TryInto smaller types, MaxValue, ToSigned, Send+Sync, Sized, Error:Debug
  • Upstream issues updated: trees-rs#30, data-rs#16

Closes #144

🤖 Generated with Claude Code

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #144
@konard konard self-assigned this Apr 14, 2026
…LinkReference

Unify the trait ecosystem by extending LinkReference with:
- TryFrom<T> and TryInto<T> (Error: Debug) for all 12 integer types
- funty(n: u8) -> Self default method for creating small constants
- Sized bound required by downstream crates

This enables platform-data and platform-trees to use LinkReference as
their single unified trait, eliminating the need for funty dependency
and reducing trait fragmentation across the ecosystem.

Closes #144

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard konard changed the title [WIP] Add TryFrom/TryInto bounds and FuntyPart-like functionality to LinkReference feat: add TryFrom/TryInto bounds, funty() method, and Sized bound to LinkReference Apr 14, 2026
@konard konard marked this pull request as ready for review April 14, 2026 10:50
@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.704023

📊 Context and tokens usage:

Claude Opus 4.6:

  • Context window: 60.1K / 1M (6%) input tokens, 12.7K / 128K (10%) output tokens

Total: (49.4K + 2.0M cached) input tokens, 12.7K output tokens, $1.618963 cost

Claude Haiku 4.5:

Total: (42.5K + 186.4K cached) input tokens, 2.7K / 64K (4%) output tokens, $0.085059 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Main model: Claude Opus 4.6 (claude-opus-4-6)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (1414KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

Can we support all doublets-rs and data-rs and tree-rs without need to mention funty or using methods named funty?

@konard konard marked this pull request as draft April 14, 2026 11:00
@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-04-14T11:00:56.124Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback.

Remove the cryptic `funty` name (an artifact of the external funty crate
dependency) and replace it with the descriptive `from_byte` method name.
This eliminates all funty references from the codebase while preserving
the same functionality: panicking conversion from u8.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard konard changed the title feat: add TryFrom/TryInto bounds, funty() method, and Sized bound to LinkReference feat: add TryFrom/TryInto bounds, from_byte() method, and Sized bound to LinkReference Apr 14, 2026
@konard konard marked this pull request as ready for review April 14, 2026 11:06
@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

Addressed the feedback — renamed funty() to from_byte() on LinkReference.

What changed

  • LinkReference::funty(n: u8) -> SelfLinkReference::from_byte(n: u8) -> Self
  • All tests, changelog, and PR description updated
  • No funty references remain anywhere in the codebase

Why from_byte (not from_u8)

from_u8 conflicts with FromPrimitive::from_u8 (which is already a supertrait of LinkReference), causing ambiguity errors at call sites. from_byte is unambiguous, descriptive, and avoids the name collision.

Ecosystem compatibility

The from_byte method provides the same functionality as FuntyPart::funty() from platform-data — downstream crates can replace T::funty(n) with T::from_byte(n) when adopting LinkReference as the unified trait.

All CI checks pass ✅

@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.936094

📊 Context and tokens usage:

Claude Opus 4.6:

  • Context window: 41.9K / 1M (4%) input tokens, 6.2K / 128K (5%) output tokens

Total: (32.8K + 950.0K cached) input tokens, 6.2K output tokens, $0.833620 cost

Claude Haiku 4.5:

Total: (40.2K + 413.3K cached) input tokens, 2.2K / 64K (3%) output tokens, $0.102474 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Main model: Claude Opus 4.6 (claude-opus-4-6)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (1153KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

Also add explicit full support for i128, u128 as we do for i68 and u68, so we can reference even more links in doublet-rs if we need too.

Also double check linksplatform/trees-rs#30 and linksplatform/data-rs#16, double check we can fully implement all requirements of these, and also update these issues to actually reflect our latest decisions on implementation (like using from_byte and full support up to i128 and u128).

Also double check all these will be able to finish linksplatform/doublets-rs#48

We need to ensure all changes are correct, consistent, validated, tested, logged and fully meet each and all discussed requirements (check issue description and all comments in issue and in pull request). Ensure all CI/CD checks pass.

@konard konard marked this pull request as draft April 14, 2026 11:13
@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-04-14T11:13:32.093Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback.

u128 already satisfied the blanket impl, but was not documented or
tested. Add u128 to trait docs, tests for from_byte, TryFrom/TryInto,
Sized, Send+Sync, Error:Debug, and large-value edge cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard konard changed the title feat: add TryFrom/TryInto bounds, from_byte() method, and Sized bound to LinkReference feat: add TryFrom/TryInto bounds, from_byte() method, Sized bound, and u128 support to LinkReference Apr 14, 2026
@konard konard marked this pull request as ready for review April 14, 2026 11:19
@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

Changes made

  1. Explicit u128 supportu128 now documented and tested as a LinkReference implementor (it already satisfied the blanket impl, just wasn't listed in docs/tests)
  2. 5 new tests for u128: trait impl, from_byte full range, TryFrom all integer types, TryInto smaller types, large value edge cases
  3. Updated u128 across all existing test groups: Sized, Send+Sync, Error:Debug, from_byte zero/one, MaxValue, ToSigned, TryFrom<u8>
  4. Total: 96 tests pass (up from 91), plus 6 doctests, zero clippy warnings

Ecosystem cross-check

Verified that LinkReference now provides a strict superset of bounds needed by:

Note on i128

i128 is not a LinkReference type (it's signed, and LinkReference requires Unsigned). However, i128 is fully supported as Number and SignedNumber, and all TryFrom<i128>/TryInto<i128> conversions are available on LinkReference types. This matches the pattern for i64 — it's a conversion target, not a link identifier.

CI running on commit dd4a7e0 — one workflow already ✅.

@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $2.272065

📊 Context and tokens usage:

Claude Opus 4.6:

  • Context window: 79.5K / 1M (8%) input tokens, 14.5K / 128K (11%) output tokens

Total: (68.4K + 2.8M cached) input tokens, 14.5K output tokens, $2.174303 cost

Claude Haiku 4.5:

Total: (37.7K + 358.6K cached) input tokens, 3.0K / 64K (5%) output tokens, $0.097763 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Main model: Claude Opus 4.6 (claude-opus-4-6)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (1778KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Member Author

konard commented Apr 14, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard konard merged commit 75d5b43 into main Apr 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TryFrom/TryInto bounds and FuntyPart-like functionality to LinkReference

1 participant